GtkSwitch: Update handle_x in size-allocate
authorMatthias Clasen <mclasen@redhat.com>
Mon, 4 Aug 2014 12:32:40 +0000 (14:32 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 4 Aug 2014 12:36:42 +0000 (14:36 +0200)
Since we are storing positions here that depend on the allocation,
we need to update them in size-allocate. This fixes incorrect
positioning of the handle if the switch is active initially.

https://bugzilla.gnome.org/show_bug.cgi?id=734213

gtk/gtkswitch.c

index b1758061d0a84c805cf6e5f5edb721b4b950057e..28962d2a9be311ac98809f700e3c6e6e9d9ce326 100644 (file)
@@ -474,6 +474,11 @@ gtk_switch_size_allocate (GtkWidget     *widget,
                             allocation->width,
                             allocation->height);
 
+  if (priv->is_active)
+    priv->handle_x = gtk_widget_get_allocated_width (widget) / 2;
+  else
+    priv->handle_x = 0;
+
   _gtk_widget_set_simple_clip (widget);
 }